<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@ taglib uri="/struts-tags" prefix="s"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath }/css/style.css">
<script type="text/javascript"
	src="${pageContext.request.contextPath }/jq/jquery-3.2.1.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath }/layer/layer.js"></script>
<script type="text/javascript">
	$(function() {

		$(".deleteuser").click(function() {
			var str = this.lang.split("!");
			if (!confirm("您确定要删除[" + str[0] + "]用户吗")) {
				return;
			}
			;
			$.post("${pageContext.request.contextPath }/user/delete", {
				"user.id" : str[1]
			}, function() {
				location.href("list.action");
			});
		});

		$(".modifyuser")
				.click(
						function() {
							location.href = "${pageContext.request.contextPath }/user/modify?user.id="
									+ this.lang + "&idType=user";
						});

		$(".picture").click(function() {
			$.getJSON("${pageContext.request.contextPath }/picture/getpic", {
				"picture.uid" : this.lang,
				"idType" : "user"
			}, function(data) {
				layer.photos({
					//		html:"",
					photos : data

				});
			});
		});

		$(".picture").each(function(i, e) {
			$.post("${pageContext.request.contextPath }/picture/getnum", {
				"picture.uid" : e.lang
			}, function(data) {
				e.innerHTML = e.innerHTML + "(" + data + ")";
			});
		});
	});
</script>

</head>
<body>
	<table class="bordered">
		<tr>
			<th>序号</th>
			<th>用户名</th>
			<th>密码</th>
			<th>照片</th>
			<th>删除</th>
			<th>修改</th>
		</tr>
		<s:iterator value="#USERLIST" status="st" id="u">
			<tr>
				<td><s:property value="#st.index+1" /></td>
				<td><s:property value="userName" /></td>
				<td><s:property value="pwd" /></td>
				<td><a href="#" class="picture" lang="<s:property value='id'/>">照片</a></td>
				<td><a href="#" class="deleteuser"
					lang="<s:property value='userName'/>!<s:property value='id'/>">删除</a></td>
				<td><a href="#" class="modifyuser"
					lang="<s:property value='id'/>">修改</a></td>
			</tr>
		</s:iterator>
	</table>
	<a href="${pageContext.request.contextPath }/main.jsp">返回主页面</a>
</body>
</html>